home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 44 / Amiga Format CD44 (1999-08-26)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-10].iso / -in_the_mag- / basics / hisoft / doc2rtf.lha / DOC2RTF.bas < prev    next >
BASIC Source File  |  1996-05-20  |  30KB  |  1,153 lines

  1. REM ------------------------------
  2. REM   DOC2RTF.bas - Mark J Swift
  3. REM   Originally Qdos SuperBASIC       
  4. REM   HiSoft BASIC 2 version SNG
  5. REM   Update v4.0, 19th May 1996
  6. REM ------------------------------
  7. REM   Now supports PC Quill DOCs
  8. REM   as well as QL + Thor files
  9. REM   adapts for screen size and
  10. REM   converts PC and QL to ANSI
  11. REM ------------------------------
  12.  
  13. ' Works from Command Line or Workbench - expects ASL
  14. ' (WB2+ or PD versions) for Workbench file selector.
  15. '
  16. ' Main v 1.012 advance is PC Quill document support.
  17. ' Workbench view is not yet properly font adaptive -
  18. ' text above 8 pitch overlaps progress indicator and
  19. ' may be too big for the window if average character
  20. ' width is more than eight pixels. Use a fixed font?
  21. ' Probably better to resize the window for the font!
  22.  
  23. ' v 1.013 includes a lot of fixes and fudges to make
  24. ' output more closely resemble that from the version
  25. ' for the QL (1.01) from which this is derived but X
  26. ' coordinates (default tabs etc) are still adrift by
  27. ' a small margin - perhaps because of Floating Point
  28. ' rounding effects? Main window + ASL requesters now
  29. ' use extra Workbench screen lines if available, but
  30. ' should still be compatible with NTSC, no overscan. 
  31. ' STILL not font adaptive, but completion indication
  32. ' has been moved to steer clear of most small fonts;
  33. ' looks fine in Topaz 8, Courier 13, LetterGothic 15
  34. ' Clean 13, System 8, Teletext 10 and smaller fonts.
  35.  
  36. ' Version 1.014 selects ANSI and escapes codes >127.
  37. ' cWidth has been tweaked by 0.2% to match QL maths.
  38. ' Update restores an extra tab for left indentation.
  39. ' Completion indicator centred in box. Mouse polling
  40. ' improved. Busy wait for mouse debounce eliminated.
  41.  
  42. REM $INCLUDE asl.bh ' HiSoft's ASL Requester support
  43.  
  44. ' Globals predominate
  45.  
  46. DIM SHARED DOCbldFlg%,DOCitaFlg%,DOCundFlg%,DOCcndFlg%,DOCsupFlg%,DOCsubFlg%
  47. DIM SHARED RTFbldFlg%,RTFitaFlg%,RTFundFlg%,RTFcndFlg%,RTFsupFlg%
  48. DIM SHARED RTFsubFlg%,RTFenhFlg%,PCtype% ' 1.012
  49. DIM SHARED RTFdefli,RTFdeffi,RTFdefri,RTFli,RTFfi,RTFri
  50. DIM SHARED RTFalignFlg%,RTFstyleFlg%,RTFparFlg%,RTFnTbs%
  51. DIM SHARED RTFo$,RTFtbs$
  52. DIM SHARED base6&,base7&,File$,InFile$,OutFile$,t,txtOffs&,tblOffs&,cWdth
  53.  
  54. DIM SHARED tblLen&,PagOffs,PagLen,GenOffs,GenLen,RulOffs,RulLen
  55. DIM SHARED DOCrulID,DOCbotM,DOCpwid,RTFpwid,DOCLineGap,DOCLinePP,DOCjFlg
  56. DIM SHARED DOCStartPag,DOCtopM,DOChjust,DOCfjust,DOChGap,DOCfGap
  57. DIM SHARED RTFextra,RTFheadery,RTFfootery,RTFmargt,RTFmargb,RTFstartPag
  58. DIM SHARED RTFmargl,RTFmargr,DOCpagFlg%,RTFleading,QUILL
  59.  
  60. ' No need to DIM strings only used in the mainline (Turbo static allocation)
  61.  
  62. 'DIM InFile$(100),OutFile$(100),verstag$(4)
  63. 'DIM RTFtbs$(256),K$(1),extra$(4),RTFo$(4096)
  64.  
  65. ' Global arrays
  66.  
  67. 1170 DIM SHARED RTFtbs%(256),ANSI%(255)
  68.  
  69. ' cWidth trimmed down (from 11880 to 11858, < 0.2%) to match QL arithmetic
  70.  
  71. cWidth=11858 : cWidth=cWidth/98:' width of 10pt courier in 1/20 pts (approx)
  72. verstag$="$VER: DOC2RTF 1.014 (19 May 1996)"' this version from Mark's 1.01
  73. RTFtbs$=STRING$(256,CHR$(0)) ' Kludge to prevent ASC on empty string abort
  74.  
  75. CommandLine%=LEN(COMMAND$)
  76.  
  77. IF CommandLine%=0
  78.     LIBRARY OPEN "asl.library"
  79.     DIM frintags&(20) ' ASL Tag arrays
  80.     DIM frouttags&(20)
  81.   OutDrawer$="RAM:" ' Path defaults
  82.   InDrawer$="QL0:"
  83.   InName$="_doc"
  84.   extraR%=(PEEKW(SYSTAB+2)-200)\2 ' Add to file requester
  85.   extra%=extraR%
  86.   IF extraR%>18 THEN extra%=18 ' Add to window is limited
  87. END IF
  88.  
  89. REPEAT outer_loop
  90.  
  91.     IF CommandLine%
  92.  
  93.         ' we have a command line - try to parse it
  94.  
  95.         InFile$=COMMAND$
  96.         IF INSTR(InFile$,"?") THEN
  97.             PRINT "Example: DOC2RTF InFile [OutFile]" ' Too terse?
  98.             SYSTEM
  99.         END IF
  100.         gap%=INSTR(InFile$," ")
  101.         gap1%=gap%
  102.  
  103.         REPEAT closeUp          
  104.           IF gap%=0 THEN EXIT closeUp
  105.           IF gap%>=LEN(InFile$) THEN gap%=0 : EXIT closeUp
  106.           IF MID$(Infile$,gap%+1,1)<"!"
  107.             gap%=gap%+1
  108.           ELSE
  109.             EXIT closeUp
  110.           END IF
  111.         END REPEAT closeUp
  112.  
  113.         IF gap%=0
  114.           OutFile$=InFile$+".RTF"
  115.         ELSE
  116.           IF UCASE$(MID$(InFile$,gap%+1,2))="TO" AND MID$(InFile$,gap%+3,1)<"!"
  117.             OutFile$=MID$(InFile$,gap%+3,1024)
  118.           ELSE
  119.               OutFile$=MID$(InFile$,gap%+1,1024)
  120.           END IF
  121.           REPEAT tidy
  122.               IF LEFT$(OutFile$,1)<"!"
  123.                 OutFile$=MID$(OutFile$,2,1024)
  124.             ELSE
  125.                 EXIT tidy ' Controls and spaces stripped from start
  126.               END IF
  127.         END REPEAT tidy
  128.           InFile$=LEFT$(InFile$,gap1%-1) ' Keep up to first space
  129.         END IF
  130.         PRINT "Converting from ";Infile$;" TO ";Outfile$
  131.               
  132.     ELSE
  133.  
  134.       ' Use Workbench screen (assume >= 640x200) ' SCREEN 1,640,200,LOG2(2),4
  135.  
  136.       WINDOW 1," DOC2RTF by Mark J Swift, version " + MID$(verstag$,14,7), _
  137.             (40,2+extra%)-(600,198+extra%),2+4+16+256
  138.             
  139.       WIDTH 72 ' Try to ensure text leaves room for a progress bar on the right
  140.  
  141.      CLS
  142.      PRINT " DOC2RTF is a file utility that translates Psion `Quill' DOC files into"
  143.      PRINT " rich text format (RTF). RTF files can be imported by Amiga Wordworth 5"
  144.      PRINT " or many Apple Macintosh & IBM PC word-processors and DTP applications."
  145.      PRINT
  146.      PRINT " FREEWARE by Mark J Swift, Rear Flat, 175 Church Street, Blackpool, FY1"
  147.      PRINT " 3NX, UK then converted to Amiga HiSoft BASIC 2 and extended by Simon N"
  148.      PRINT " Goodwin May 1995 to May 1996 using extra information from Chas Dillon."
  149.      PRINT
  150.           
  151.     ' No command line so use the ASL file requester (expects WB2 and up)
  152.  
  153.         TAGLIST VARPTR(frintags&(0)),ASLFR_TitleText&,"Quill file selector", _
  154.                 ASLFR_InitialFile&,InName$, _
  155.                 ASLFR_InitialDrawer&, InDrawer$, _
  156.                 ASLFR_InitialHeight&, 150+ExtraR%, _
  157.                 ASLFR_InitialLeftEdge&, 320, _
  158.                 ASLFR_InitialTopEdge&, 50+extraR%, _ 
  159.                 TAG_DONE&
  160.         fr&=AllocAslRequest&(ASL_FileRequest&,VARPTR(frintags&(0)))
  161.         IF fr& THEN
  162.             IF AslRequest&(fr&,0) THEN
  163.             ' A file name was entered; build the full path
  164.                 InDrawer$=PEEK$(PEEKL(fr&+fr_Drawer%)): filename$=InDrawer$
  165.               IF RIGHT$(InDrawer$,1)<>":" THEN filename$=filename$+"/" 
  166.               InName$=PEEK$(PEEKL(fr&+fr_File%))
  167.                 filename$=filename$+InName$
  168.             ELSE
  169.               filename$=""        
  170.             END IF
  171.             FreeASlRequest fr&
  172.         InFile$=filename$
  173.         PRINT " Reading from ";InFile$
  174.         ELSE
  175.         INPUT "      Input source DOC filename  >";InFile$
  176.          END IF
  177.  
  178.       IF InFile$="" THEN EXIT outer_loop
  179.       IF UCASE$(RIGHT$(InName$,3))="DOC" ' v 1.012 allows .DOC and _DOC
  180.         OutFile$=LEFT$(InName$,LEN(InName$)-3)+"RTF"
  181.       ELSE
  182.         OutFile$=InName$+".RTF"
  183.       END IF
  184.  
  185.         TAGLIST VARPTR(frouttags&(0)), _
  186.             ASLFR_TitleText&,"Rich Text Format file selector", _
  187.                 ASLFR_InitialFile&, OutFile$, _
  188.                 ASLFR_InitialDrawer&, OutDrawer$, _
  189.                 ASLFR_InitialHeight&, 150+extraR%, _
  190.                 ASLFR_InitialLeftEdge&, 310, _
  191.                 ASLFR_InitialTopEdge&, 50+extraR%, _ 
  192.                 TAG_DONE&
  193.       fr&=AllocAslRequest&(ASL_FileRequest&,VARPTR(frouttags&(0)))
  194.         IF fr& THEN
  195.             IF AslRequest&(fr&,0) THEN
  196.             ' A file name was entered; build the full path
  197.                 filename$=PEEK$(PEEKL(fr&+fr_Drawer%))
  198.               IF RIGHT$(filename$,1)<>":" THEN filename$=filename$+"/" 
  199.               filename$=filename$+PEEK$(PEEKL(fr&+fr_File%))
  200.             ELSE
  201.               filename$=""        
  202.             END IF
  203.             FreeASlRequest fr&
  204.         OutFile$=filename$
  205.         PRINT " Writing to ";OutFile$
  206.         ELSE
  207.       INPUT " Input destination RTF filename  >";OutFile$
  208.       END IF
  209.       IF OutFile$="" THEN EXIT outer_loop
  210.  
  211.       PRINT " Loading...";
  212.       LINE (519,61)-(569,176),0,bf
  213.       LINE (519,61)-(569,176),2,b
  214.       LINE (520,62)-(570,177),1,b
  215.  
  216.     END IF ' Interactive
  217.  
  218.     ' Process entire document, a paragraph at a time
  219.  
  220.     DOCbeginDocument InFile$
  221.  
  222.     IF QUILL=0 
  223.       PRINT InFile$;" is not a Quill document!"
  224.       IF CommandLine% THEN SYSTEM
  225.       PRINT " Please tap to continue, then make another selection." 
  226.     ELSE
  227.       IF CommandLine%=0 THEN PRINT " Converting...";
  228.       RTFleading=240
  229.       IF (DOChjust<>0) THEN CALL DOCdoHeader
  230.       IF (DOCfjust<>0) THEN CALL DOCdoFooter
  231.       CALL DOCclearEnhance
  232.       Base6&=Base6&+14+14 ' 1.013, skip header and footer
  233.       RTFleading=240*(1+DOCLineGap)
  234.       REPEAT tblLoop
  235.         IF Base7&>tblOffs& THEN EXIT tblLoop
  236.         DOCdoParagraph
  237.         IF CommandLine%=0
  238.           IF txtOffs&>tblOffs& THEN 
  239.             LINE (530,69)-(560,169),1,bf
  240.           ELSE 
  241.             LINE (530,69)-(560,69+txtOffs&*100\tblOffs&),1,bf
  242.           END IF
  243.         END IF
  244.       END REPEAT tblLoop
  245.       CALL DOCendDocument
  246.       REM RETRY_HERE
  247.       IF CommandLine% THEN EXIT outer_loop
  248.       PRINT " Done - tap to continue.";
  249.     END IF
  250.     
  251.     CALL MouseWait
  252.  
  253. END REPEAT outer_loop
  254.  
  255. SYSTEM ' Formerly STOP but no need for keypress
  256.  
  257. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  258.  
  259. ' Amiga specific routines
  260.   
  261. SUB MouseWait
  262. LOCAL key$ ' No need to share here
  263.  
  264. REPEAT debounce
  265.   IF MOUSE(0)<2 THEN EXIT debounce
  266.   SLEEP
  267. END REPEAT debounce
  268.  
  269. REPEAT poll
  270.   SLEEP : key$=INKEY$
  271.   IF MOUSE(0) THEN key$=CHR$(0)
  272.   IF LEN(key$) THEN EXIT poll 
  273. END REPEAT poll
  274.  
  275. END SUB ' MouseWait
  276.  
  277. REM NUM$ is a replacement for STR$ with two advantages:
  278. REM Includes Zero before the point in numbers from 0..1
  279. REM No leading space before positive numbers (bug-fix). 
  280.  
  281. FUNCTION NUM$(VAL x)
  282. STATIC t$
  283. t$=STR$(x)
  284.   IF x>=0
  285.     t$=MID$(t$,2,15)
  286.     IF x<1 AND x>=.1 THEN t$="0"+t$
  287.   END IF
  288.   IF RIGHT$(t$,1)=" " THEN t$=LEFT$(t$,LEN(t$)-1) :REM Skip trailing space
  289.   NUM$=t$
  290. END FUNCTION
  291.  
  292. ' v 1.012 - PC little-endian byte reversal functions
  293.  
  294. FUNCTION WORD&(t$)
  295. IF PCtype%
  296.   WORD&=ASC(LEFT$(t$,1))+256*ASC(MID$(t$,2,1))
  297. ELSE
  298.   WORD&=CVI(t$)
  299. END IF
  300. END FUNCTION
  301.  
  302. FUNCTION LONG&(t$)
  303. IF PCtype%
  304.   LONG&=WORD&(LEFT$(t$,2))+65536*WORD&(MID$(t$,3,2))
  305. ELSE
  306.   LONG&=CVL(t$)
  307. END IF
  308. END FUNCTION
  309.  
  310. FUNCTION HEX4$(b%)
  311.   HEX4$=MID$("0123456789abcdef",b%+1,1)
  312. END FUNCTION
  313.  
  314. FUNCTION HEX8$(c%)
  315.   HEX8$=HEX4$(c% >> 4)+HEX4$(c% AND 15)
  316. END FUNCTION
  317.  
  318. SUB SignedByte6
  319. t=ASC(MID$(File$,Base6&,1))
  320. IF t>128 THEN t=128-t
  321. Base6&=Base6&+1
  322. END SUB
  323.  
  324. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  325.  
  326. ' Quill document input routines
  327.  
  328. SUB DOCbeginDocument(InFile$)
  329. LOCAL length,K,PCtype% ' Update for PC Quill, 23/9/95
  330. DIM SHARED cWidth
  331.  
  332.  ' Read file into a string for random access
  333.  OPEN InFile$ FOR INPUT AS #6
  334.  length=LOF(6)
  335.  File$=INPUT$(length,#6)
  336.  CLOSE #6
  337.  
  338.  ' Check it's a valid Psion Quill file
  339.  
  340.  QUILL=0
  341.  IF length<512 THEN EXIT SUB
  342.  IF MID$(File$,3,8)<>"vrm1qdf0" THEN EXIT SUB
  343.  QUILL=1
  344.  
  345.  ' Distinguish between MSDOS and QDOS ASCII 
  346.  
  347.  PCtype%=CVI(LEFT$(File$,2))<>20
  348.  
  349.  IF PCtype%
  350.    RESTORE PC_CODES
  351.  ELSE
  352.    RESTORE QL_CODES
  353.  END IF
  354.  
  355.  FOR K=127 TO 255
  356.    READ ANSI%(K)
  357.  NEXT K
  358.               
  359.  base7&=1 ' Position in string (SuperBASIC #7 file pointer)
  360.  tblOffs&=LONG&(MID$(File$,11,4))
  361.  base6&=tblOffs&+22+1
  362.  tblLen&=WORD&(MID$(File$,15,2))
  363.  PagOffs=tblOffs&+tblLen&
  364.  PagLen=WORD&(MID$(File$,17,2))
  365.  GenOffs=PagOffs+PagLen
  366.  GenLen=WORD&(MID$(File$,19,2))
  367.  RulOffs=GenOffs+20+PCtype%*2
  368.  RulLen=GenLen-20-PCtype%*2
  369.  GenLen=GenLen-RulLen
  370.  DOCclearEnhance
  371.  DOCrulID=0
  372.  DOCbotM=ASC(MID$(File$,GenOffs+1,1))
  373.  K=ASC(MID$(File$,GenOffs+2,1))
  374.  SELECT ON K
  375.    =1         :DOCpwid=40
  376.    =2         :DOCpwid=64
  377.    =REMAINDER :DOCpwid=80
  378.  END SELECT 
  379.  RTFpwid=INT(cWidth*DOCpwid+.5)
  380.  DOCLineGap=ASC(MID$(File$,GenOffs+3-PCtype%,1))
  381.  DOCLinePP=ASC(MID$(File$,GenOffs+4-PCtype%,1))
  382.  DOCStartPag=ASC(MID$(File$,GenOffs+5-PCtype%,1))
  383.     
  384.  PCtype%=PCtype%*2
  385.  ' Skip Qdos display colour at +6 as well as colour at +2
  386.  DOCtopM=ASC(MID$(File$,GenOffs+7-PCtype%,1))
  387.  DOChjust=ASC(MID$(File$,GenOffs+15-PCtype%,1))
  388.  DOCfjust=ASC(MID$(File$,GenOffs+16-PCtype%,1))
  389.  DOChgap=ASC(MID$(File$,GenOffs+17-PCtype%,1))
  390.  DOCfGap=ASC(MID$(File$,GenOffs+18-PCtype%,1))
  391.  
  392.  IF DOCLinePP>70 THEN DOCLinePP=70
  393.  RTFextra=240*(70-DOCLinePP)/2
  394.  RTFheadery=240*DOCtopM+RTFextra
  395.  RTFfootery=240*DOCbotM+RTFextra
  396.  RTFmargt=RTFheadery
  397.  IF (DOChjust<>0) THEN RTFmargt=RTFmargt+240*(1+DOChGap)
  398.  RTFmargb=RTFfootery
  399.  IF (DOCfjust<>0) THEN RTFmargb=RTFmargb+240*(DOCfGap+1)
  400.  RTFstartPag=DOCStartPag
  401.  CALL RTFbeginDocument(OutFile$)
  402.  
  403. END SUB 
  404.  
  405. SUB DOCendDocument
  406.  CALL RTFendDocument
  407. END SUB 
  408.  
  409. SUB DOCdoFooter
  410. SHARED File$
  411.  RTFbeginFooter
  412.  txtOffs&=LONG&(MID$(File$,tblOffs&+22+15,4))
  413.  DOCdoHeaderFooter(GenOffs+16-PCtype%)
  414.  CALL RTFendFooter
  415. END SUB
  416.  
  417. SUB DOCdoHeader
  418.  RTFbeginHeader
  419.  txtOffs&=LONG&(MID$(File$,tblOffs&+23,4))
  420.  DOCdoHeaderFooter(GenOffs+15-PCtype%)
  421.  CALL RTFendHeader
  422. END SUB
  423.  
  424. SUB DOCdoHeaderFooter(p&)
  425. LOCAL Kk,k$,k
  426.  
  427.  DOCclearEnhance
  428.  DOCjFLG=ASC(MID$(File$,p&,1))
  429.  
  430.  SELECT ON DOCjFlg
  431.   =1:RTFleftAlign
  432.   =2:RTFcentreAlign
  433.   =3:RTFrightAlign
  434.  END SELECT 
  435.  
  436.  Kk=ASC(MID$(File$,p&+4,1))
  437.  IF Kk<>0 THEN CALL DOCbold
  438.  p&=txtOffs&+1
  439.  REPEAT txtLoop
  440.   IF p&>LEN(File$) THEN EXIT txtLoop
  441.   k$=MID$(File$,p&,1) : p&=p&+1
  442.   k=ASC(k$)
  443.   IF K=0 THEN EXIT txtLoop
  444.   CALL RTFoutChar(K$)
  445.  END REPEAT txtLoop
  446.  
  447.  IF Kk<>0 THEN CALL DOCbold
  448.  
  449.  REPEAT pnum
  450.   K=INSTR(RTFo$,"nnn")
  451.   IF K=0 THEN K=INSTR(RTFo$,"NNN")
  452.   IF K=0 THEN K=INSTR(RTFo$,"aaa")
  453.   IF K=0 THEN K=INSTR(RTFo$,"AAA")
  454.   IF K=0 THEN EXIT pnum
  455.   IF K=(LEN(RTFo$)-2) THEN 
  456.    RTFo$=LEFT$(RTFo$,K-1)+"\chpgn "
  457.   ELSE 
  458.    RTFo$=LEFT$(RTFo$,K-1)+"\chpgn "+MID$(RTFo$,K+3,99999)
  459.   END IF 
  460.  END REPEAT pnum
  461.  
  462. END SUB
  463.  
  464. SUB DOCdoParagraph
  465. LOCAL k%,p&,L%,I%,Kk% ' Indents changed for v 1.013
  466.  
  467.  txtOffs&=1+LONG&(MID$(File$,Base6&,4))
  468.  DOCclearEnhance
  469.  
  470.  IF txtOffs&<>0 THEN 
  471.    Base7&=txtOffs&
  472.    Base6&=Base6&+7
  473.    CALL SignedByte6
  474.    RTFleftIndent INT((t+1)*cWidth+.5)
  475.    CALL SignedByte6
  476.    RTFfirstIndent (INT((t+1)*cWidth+.5)-RTFli)
  477.    CALL SignedByte6
  478.    RTFrightIndent INT(RTFpwid-t*cWidth+.5)
  479.    CALL SignedByte6
  480.    
  481.    '1970   DOCjFlg=t
  482.    
  483.    SELECT ON t
  484.      =0,4:RTFleftAlign
  485.      =1,5:RTFcentreAlign
  486.      =2,6:RTFjustify
  487.    END SELECT 
  488.    
  489.    K%=ASC(MID$(File$,Base6&,1))
  490.    Base6&=Base6&+3
  491.    
  492.    IF K%<>DOCrulID THEN 
  493.    
  494.        DOCrulID=K%
  495.        p&=RulOffs+1
  496.        
  497.        REPEAT loo
  498.          K%=ASC(MID$(File$,p&,1)) : p&=p&+1
  499.          L%=ASC(MID$(File$,p&,1))-2 : p&=p&+1 ' Fix? -2 in v 1.012
  500.          IF K%=DOCrulID THEN EXIT loo
  501.          IF L%>0 THEN p&=p&+L%
  502.        END REPEAT loo
  503.        RTFnTbs%=0
  504.    
  505.      FOR I%=1 TO L%\2
  506.        K%=ASC(MID$(File$,p&,1)) : p&=p&+1
  507.        Kk%=ASC(MID$(File$,p&,1)) : p&=p&+1
  508.        SELECT ON Kk%
  509.          =0:RTFtab INT((K%+1)*cWidth+.5),"L"
  510.          =1:RTFtab INT((K%+1)*cWidth+.5),"C"
  511.          =2:RTFtab INT((K%+1)*cWidth+.5),"R"
  512.          =3:RTFtab INT((K%+1)*cWidth+.5),"D"
  513.        END SELECT 
  514.      NEXT I%
  515.      
  516.    END IF
  517.    RTFleftIndent RTFli
  518.  
  519. '    debug: PRINT LEFT$(RTFtbs$,RTFnTbs%),RTFnTbs% : MouseWait
  520.  
  521.   CALL RTFbeginParagraph
  522.  
  523.   REPEAT txtLoop
  524.    IF Base7&>LEN(File$) THEN EXIT txtLoop
  525.    k%=ASC(MID$(File$,Base7&,1)) : Base7&=Base7&+1
  526.    
  527.    SELECT ON k%
  528.      =0:EXIT txtLoop
  529.      =9:RTFtabout
  530.     =12:DOCpagFlg%=1 ' v 1.013
  531.     =15:DOCbold
  532.     =18:DOCsuperscript
  533.     =17:DOCsubscript
  534.     =16:DOCunderline
  535.     =30:RTFoutChar "-"
  536.     =19:DOCitalic ' v 1.012, for PC Quill    
  537.     =REMAINDER : RTFoutChar CHR$(k%) ' This is where it's slow!
  538.    END SELECT 
  539.    
  540.   END REPEAT txtLoop
  541.  
  542.   CALL RTFendParagraph
  543.  
  544. END IF
  545. END SUB
  546.  
  547. SUB DOCclearEnhance
  548.  DOCbldFlg%=0
  549.  DOCitaFlg%=0
  550.  DOCundFlg%=0
  551.  DOCcndFlg%=0
  552.  DOCsupFlg%=0
  553.  DOCsubFlg%=0
  554. END SUB
  555.  
  556. SUB DOCbold
  557.  DOCbldFlg%=1-DOCbldFlg%
  558.  IF DOCbldFlg% THEN 
  559.   CALL RTFboldON
  560.  ELSE 
  561.   CALL RTFboldOFF
  562.  END IF 
  563. END SUB 
  564.  
  565. SUB DOCsuperscript
  566.  DOCsupFlg%=1-DOCsupFlg%
  567.  IF DOCsupFlg% THEN 
  568.   CALL RTFsuperscriptON
  569.  ELSE 
  570.   CALL RTFsuperscriptOFF
  571.  END IF 
  572. END SUB 
  573.  
  574. SUB DOCsubscript
  575.  DOCsubFlg%=1-DOCsubFlg%
  576.  IF DOCsubFlg% THEN 
  577.   CALL RTFsubscriptON
  578.  ELSE 
  579.   CALL RTFsubscriptOFF
  580.  END IF 
  581. END SUB 
  582.  
  583. SUB DOCunderline
  584.  DOCundFlg%=1-DOCundFlg%
  585.  IF DOCundFlg% THEN 
  586.   CALL RTFunderlineON
  587.  ELSE 
  588.   CALL RTFunderlineOFF
  589.  END IF 
  590. END SUB 
  591.  
  592. SUB DOCitalic
  593.  DOCitaFlg%=1-DOCitaFlg%
  594.  IF DOCitaFlg% THEN 
  595.   CALL RTFitalicON
  596.  ELSE 
  597.   CALL RTFitalicOFF
  598.  END IF 
  599. END SUB ' Added in v1.012 for PC Quill
  600.  
  601. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  602.  
  603. ' Rich Text format output routines, adapted from Mark's QL SuperBASIC
  604. ' Line numbers from the original source remain but are no longer used
  605.  
  606. 2600 SUB RTFbeginDocument(OutFile$)
  607. 2610
  608. 2620  RTFbldFlg%=0
  609. 2630  RTFitaFlg%=0
  610. 2640  RTFundFlg%=0
  611. 2650  RTFcndFlg%=0
  612. 2660  RTFsupFlg%=0
  613. 2670  RTFsubFlg%=0
  614. 2680  RTFenhFlg%=1
  615. 2690
  616. 2700  RTFdefli=0
  617. 2710  RTFdeffi=0
  618. 2720  RTFdefri=0
  619. 2730  RTFli=RTFdefli
  620. 2740  RTFfi=RTFdeffi
  621. 2750  RTFri=RTFdefri
  622. 2760
  623. 2770  RTFalignFlg%=0
  624. 2780
  625. 2790  RTFstyleFlg%=0
  626. 2800  RTFparFlg%=0
  627. 2810
  628. 2820  RTFnTbs%=0
  629. 2830
  630. 2840  OPEN OutFile$ FOR OUTPUT AS #9
  631. 2850  PRINT#9,"{\rtf0 \ansi"
  632. 2860  PRINT#9,""
  633. 2870  PRINT#9,"{\fonttbl"
  634. 2880  PRINT#9,"{\f22 \fmodern Courier;}"
  635. 2890  PRINT#9,"}"
  636. 2900  PRINT#9,""
  637. 2910  PRINT#9,"{\stylesheet"
  638. 2920  PRINT#9,"{\s243 \qc \f22 \fs20 \sbasedon0 \snext243 footer;}"
  639. 2930  PRINT#9,"{\s244 \qc \f22 \fs20 \sbasedon0 \snext244 header;}"
  640. 2940  PRINT#9,"{\f22 \fs20 \sbasedon222 \snext0 Normal;}"
  641. 2950  PRINT#9,"}"
  642. 2960  PRINT#9,""
  643. 2961  RTFmargl=1080
  644. 2962  RTFmargr=11880-RTFpwid-RTFmargl
  645. 2970  PRINT#9,"\paperw11880 \paperh16800 \deftab";NUM$(INT(cWidth*5))
  646. 2975  PRINT#9,"\margl";NUM$(RTFmargl);" \margr";NUM$(RTFmargr);
  647.       PRINT#9," \margt";NUM$(-RTFmargt);" \margb";NUM$(-RTFmargb)
  648. 2980  PRINT#9,"\widowctrl \ftnbj \pgnstart";NUM$(RTFstartPag);" \fracwidth "
  649. 2985  PRINT#9,"\sectd \linemod0 \linex0 \headery";NUM$(RTFheadery);
  650.       PRINT#9," \footery";NUM$(RTFfootery);" \cols1 \endnhere"
  651. 2990  PRINT#9,"\plain \f22 \fs20 "
  652. 3000  PRINT#9,""
  653. 3010  RTFo$=""
  654. 3020 END SUB 
  655. 3030
  656. 3040 SUB RTFendDocument
  657. 3050
  658. 3060  IF RTFparFlg% THEN 
  659. 3070    CALL RTFendParagraph
  660. 3080  END IF 
  661. 3090
  662. 3100  PRINT#9,"}"
  663. 3110  CLOSE#9
  664. 3120 END SUB 
  665.  
  666. SUB RTFbeginHeader
  667. 3123  PRINT#9;"{\header "
  668.       CALL RTFbeginParagraph
  669.       RTFo$=RTFo$+"\s244 \f22 \fs20 "
  670. END SUB
  671.  
  672. SUB RTFendHeader
  673. 3128  CALL RTFendParagraph:PRINT#9;"}":CALL RTFclearStyle
  674. END SUB
  675.  
  676. SUB RTFbeginFooter
  677. 3133  PRINT#9;"{\footer "
  678.       CALL RTFbeginParagraph
  679.       RTFo$=RTFo$+"\s243 \f22 \fs20 "
  680. END SUB
  681.  
  682. SUB RTFendFooter
  683.   CALL RTFendParagraph
  684.   PRINT#9;"}"
  685.   CALL RTFclearStyle
  686. END SUB
  687.  
  688. 3140 SUB RTFbeginParagraph
  689. 3150  IF rtfparFlg% THEN 
  690. 3160   CALL RTFendParagraph
  691. 3200  END IF 
  692. 3220  rtfparFlg%=1
  693. 3225  CALL RTFclearEnhance
  694. 3227  DOCpagFlg%=0
  695. 3230 END SUB 
  696.  
  697. 3250 SUB RTFendParagraph
  698. 3260  IF RTFparFlg% THEN 
  699. 3270    CALL RTFendEnhance
  700. 3280    RTFo$=RTFo$+"\par "
  701. 3285    RTFflushStyle
  702. 3290    PRINT#9,RTFo$
  703. 3295    CALL RTFclearEnhance
  704. 3300    RTFo$=""
  705. 3310    rtfparFlg%=0
  706. 3315    IF DOCpagFlg%<>0 THEN 
  707. 3316     CALL RTFpagebreak
  708. 3317     DOCpagFlg%=0
  709. 3318    END IF 
  710. 3320  END IF 
  711. 3330 END SUB 
  712.  
  713. SUB RTFclearStyle
  714. 3333  RTFdefli=0
  715. 3334  RTFdeffi=0
  716. 3335  RTFdefri=0
  717. 3336  RTFli=RTFdefli
  718. 3337  RTFfi=RTFdeffi
  719. 3338  RTFri=RTFdefri
  720. 3339 :
  721. 3340  RTFalignFlg%=0
  722. 3341 :
  723. 3342  RTFnTbs%=0
  724. 3344 :
  725. 3345  RTFstyleFlg%=0
  726. END SUB
  727.  
  728. 3350 SUB RTFleftAlign
  729. 3360  IF RTFalignFlg%<>0 THEN 
  730. 3370   RTFalignFlg%=0
  731. 3380   RTFstyleFlg%=1
  732. 3390  END IF 
  733. 3400 END SUB 
  734.  
  735. 3420 SUB RTFrightAlign
  736. 3430  IF RTFalignFlg%<>1 THEN 
  737. 3440   RTFalignFlg%=1
  738. 3450   RTFstyleFlg%=1
  739. 3460  END IF 
  740. 3470 END SUB 
  741.  
  742. 3490 SUB RTFcentreAlign
  743. 3500  IF RTFalignFlg%<>2 THEN 
  744. 3510   RTFalignFlg%=2
  745. 3520   RTFstyleFlg%=1
  746. 3530  END IF 
  747. 3540 END SUB 
  748.  
  749. 3560 SUB RTFjustify
  750. 3570  IF RTFalignFlg%<>3 THEN 
  751. 3580   RTFalignFlg%=3
  752. 3590   RTFstyleFlg%=1
  753. 3600  END IF 
  754. 3610 END SUB 
  755.  
  756. 3630 SUB RTFleftIndent(N)
  757. 3640  REM n - units of pts/20 as measured from the left margin
  758. 3650  IF N<>RTFli THEN 
  759. 3660    RTFli=N
  760. 3670    RTFstyleFlg%=1
  761. 3680  END IF 
  762. 3682  IF RTFstyleFlg%<>0 THEN 
  763. 3685   CALL RTFclearSoftTabs
  764. 3690   RTFtab N,"S"
  765. 3695  END IF 
  766. '3690  RTFtab N,"L" - previous TABless version
  767. 3700 END SUB 
  768.  
  769. 3720 SUB RTFfirstIndent(N)
  770. 3730  REM n - units of pts/20 as measured from the left indent
  771. 3740  IF N<>RTFfi THEN 
  772. 3750    RTFfi=N
  773. 3760    RTFstyleFlg%=1
  774. 3770  END IF 
  775. 3780 END SUB 
  776.  
  777. 3800 SUB RTFrightIndent(N)
  778. 3810  REM n - units of pts/20 as measured from the right margin
  779. 3820  IF N<>RTFri THEN 
  780. 3830    RTFri=N
  781. 3840    RTFstyleFlg%=1
  782. 3850  END IF 
  783. 3860 END SUB 
  784.  
  785. SUB RTFclearSoftTabs
  786. LOCAL tp$,i,j
  787. 3863  i=1
  788. 3864  REPEAT loo
  789. 3865   IF i>RTFnTbs% THEN EXIT loo
  790. '3866  IF RTFtbs$(i)=="S" THEN 
  791.        tp$=MID$(RTFtbs$,i,1)
  792.        IF tp$="S" OR tp$="s"
  793. 3867    FOR j=i TO RTFnTbs%-1
  794. 3868     RTFtbs%(j)=RTFtbs%(j+1)
  795. 3869     MID$(RTFtbs$,j,1)=MID$(RTFtbs$,j+1,1)
  796. 3870    NEXT j
  797. 3871    RTFnTbs%=RTFnTbs%-1
  798. 3872    RTFstyleFlg%=1
  799. 3873   END IF 
  800. 3874   i=i+1
  801. 3875  END REPEAT loo
  802. END SUB
  803.  
  804. 3880 SUB RTFtab(N,t$)
  805. 3890  LOCAL i,j
  806. 3900  REM n  - units of pts/20 as measured from the left margin
  807. 3910  REM t$ - L=left tab, C=centre tab, R=right tab, D=decimal tab
  808.             REM S=Soft tab, X=Remove old tab at this position
  809.       REM Updated from Qdos version 1.01, April/May 1996
  810. 3920
  811. 3930  i=1
  812. 3940  REPEAT poll
  813. 3950    IF ((i>RTFnTbs%) OR (RTFtbs%(i)>=N)) THEN EXIT poll
  814. 3960    i=i+1
  815. 3970  END REPEAT poll
  816. 3980
  817. 3981  IF t$=="X" THEN 
  818. 3982    IF i<=RTFnTbs% THEN 
  819. 3983      REM remove old tab
  820. 3984      FOR j=i TO RTFnTbs%-1
  821. 3985        RTFtbs%(j)=RTFtbs%(j+1)
  822.             MID$(RTFtbs$,j,1)=MID$(RTFtbs$,j+1,1)
  823.           NEXT j
  824. 3988      RTFnTbs%=RTFnTbs%-1
  825. 3989      RTFstyleFlg%=1
  826. 3990    END IF 
  827. 3991  ELSE 
  828.  
  829. '       PRINT n;t$;i;"of";RTFnTbs% : MouseWait ' Debug line
  830.  
  831. 3992    IF i>RTFnTbs% THEN 
  832. 3995      REM add new tab to end of Q
  833. 4000      RTFnTbs%=RTFnTbs%+1
  834. 4010      RTFtbs%(RTFnTbs%)=N
  835. 4020      MID$(RTFtbs$,RTFnTbs%,1)=t$
  836. 4030      RTFstyleFlg%=1
  837. 4040    ELSE 
  838. 4050      IF N=RTFtbs%(i) THEN 
  839. 4055        REM Replace old tab with new
  840.             IF t$<>"S" AND t$<>"s"
  841. 4060          IF MID$(RTFtbs$,i,1)<>t$ THEN 
  842. 4070            MID$(RTFtbs$,i,1)=t$
  843. 4080            RTFstyleFlg%=1
  844. 4090          END IF
  845. 4095        END IF 
  846. 4100      ELSE
  847. 4105        REM Insert new tab
  848. 4110        RTFnTbs%=RTFnTbs%+1
  849. 4120        FOR j=RTFnTbs%-1 TO i STEP -1
  850. 4130          RTFtbs%(j+1)=RTFtbs%(j)
  851. 4140          MID$(RTFtbs$,(j+1),1)=MID$(RTFtbs$,j,1)
  852. 4150        NEXT j
  853. 4160        RTFtbs%(i)=N
  854. 4170        MID$(RTFtbs$,i,1)=t$
  855. 4180        RTFstyleFlg%=1
  856. 4190      END IF 
  857. 4200    END IF
  858. 4210  END IF
  859. 4220 END SUB
  860. 4230
  861. 4240 SUB RTFflushStyle
  862. 4250  LOCal i,t,t$
  863. 4260
  864. 4270  IF RTFstyleFlg% THEN 
  865. 4280    t=RTFalignFlg%
  866. 4290    SELect ON t
  867. 4300    =0:t$="\pard "
  868. 4310    =1:t$="\pard \qr "
  869. 4320    =2:t$="\pard \qc "
  870. 4330    =3:t$="\pard \qj "
  871. 4340    END SELECT 
  872.  
  873. 4355    t$=t$+"\sl"+NUM$(RTFleading)+" "
  874.  
  875. 4360    IF RTFli<>RTFdefli THEN 
  876. 4370     t$=t$ + "\li" + NUM$(RTFli) + " "
  877. 4380    END IF 
  878. 4390
  879. 4400    IF RTFfi<>RTFdeffi THEN 
  880. 4410     t$=t$ + "\fi" + NUM$(RTFfi) + " "
  881. 4420    END IF 
  882. 4430
  883. 4440    IF RTFri<>RTFdefri THEN 
  884. 4450     t$=t$ + "\ri" + NUM$(RTFri) + " "
  885. 4460    END IF 
  886. 4470
  887. 4480    IF RTFnTbs%<>0 THEN 
  888. 4490      FOR i=1 TO RTFnTbs%
  889. 4500        t=ASC(MID$(RTFtbs$,i,1))
  890. 4510        SELect ON t
  891. 4520        =ASC("L"),ASC("S")
  892. 4530          REM left tab or soft tab (v1.01)
  893. 4540          t$=t$ + "\tx" + NUM$(RTFtbs%(i)) + " "
  894. 4550        =ASC("C")
  895. 4560          REM centre tab
  896. 4570          t$=t$ + "\tqc\tx" + NUM$(RTFtbs%(i)) + "  "
  897. 4580        =ASC("R")
  898. 4590          REM right tab
  899. 4600          t$=t$ + "\tqr\tx" + NUM$(RTFtbs%(i)) + " "
  900. 4610        =ASC("D")
  901. 4620          REM decimal tab
  902. 4630          t$=t$ + "\tqdec\tx" + NUM$(RTFtbs%(i)) + " "
  903. 4640        END SELect 
  904. 4650      NEXT i
  905. 4660    END IF 
  906. 4670
  907. 4680    RTFo$=t$ + RTFo$
  908. 4690
  909. 4700    RTFstyleFlg%=0
  910. 4710  END IF 
  911. 4720 END SUB 
  912.  
  913. 4740 SUB RTFboldON
  914. 4750  IF RTFbldFlg%=0 THEN 
  915. 4760   CALL RTFendEnhance
  916. 4770   RTFbldFlg%=1
  917. 4775   RTFenhFlg%=1 ' 1.01
  918. 4780  END IF 
  919. 4790 END SUB 
  920.  
  921. 4810 SUB RTFboldOFF
  922. 4820  IF RTFbldFlg%<>0 THEN 
  923. 4830   RTFendEnhance
  924. 4840   RTFbldFlg%=0
  925. 4845   RTFenhFlg%=RTFbldFlg% OR RTFitaFlg% OR RTFundFlg% OR RTFcndFlg% OR RTFsupFlg% OR RTFsubFlg%
  926. 4850  END IF 
  927. 4860 END SUB 
  928.  
  929. 4880 SUB RTFitalicON
  930. 4890  IF RTFitaFlg%=0 THEN 
  931. 4900   CALL RTFendEnhance
  932. 4910   RTFitaFlg%=1
  933. 4915   RTFenhFlg%=1
  934. 4920  END IF 
  935. 4930 END SUB 
  936.  
  937. 4950 SUB RTFitalicOFF
  938. 4960  IF RTFitaFlg%<>0 THEN 
  939. 4970   CALL RTFendEnhance
  940. 4980   RTFitaFlg%=0
  941. 4990  END IF 
  942. 5000 END SUB
  943.  
  944. 5020 SUB RTFunderlineON
  945. 5030  IF RTFundFlg%=0 THEN 
  946. 5040   CALL RTFendEnhance
  947. 5050   RTFundFlg%=1
  948.        RTFenhFlg%=1
  949. 5060  END IF 
  950. 5070 END SUB 
  951.  
  952. 5090 SUB RTFunderlineOFF
  953. 5100  IF RTFundFlg%<>0 THEN 
  954. 5110   CALL RTFendEnhance
  955. 5120   RTFundFlg%=0
  956.        RTFenhFlg%=RTFbldFlg% OR RTFitaFlg% OR RTFundFlg% OR RTFcndFlg% OR RTFsupFlg% OR RTFsubFlg%
  957.        RTFenhFlg%=1
  958. 5130  END IF 
  959. 5140 END SUB 
  960.  
  961. 5160 SUB RTFcondensedON
  962. 5170  IF RTFcndFlg%=0 THEN 
  963. 5180   CALL RTFendEnhance
  964.        RTFenhFlg%=1
  965. 5190   RTFcndFlg%=1
  966. 5200  END IF 
  967. 5210 END SUB 
  968.  
  969. 5230 SUB RTFcondensedOFF
  970. 5240  IF RTFcndFlg%<>0 THEN 
  971. 5250   CALL RTFendEnhance
  972. 5260   RTFcndFlg%=0
  973.        RTFenhFlg%=RTFbldFlg% OR RTFitaFlg% OR RTFundFlg% OR RTFcndFlg% OR RTFsupFlg% OR RTFsubFlg%
  974. 5270  END IF 
  975. 5280 END SUB 
  976.  
  977. 5300 SUB RTFsuperscriptON
  978. 5310  IF RTFsupFlg%=0 THEN 
  979. 5320   CALL RTFendEnhance
  980.        RTFenhFlg%=1
  981. 5330   RTFsupFlg%=1
  982. 5340  END IF 
  983. 5350 END SUB 
  984.  
  985. 5370 SUB RTFsuperscriptOFF
  986. 5380  IF RTFsupFlg%<>0 THEN 
  987. 5390   CALL RTFendEnhance
  988. 5400   RTFsupFlg%=0
  989.        RTFenhFlg%=RTFbldFlg% OR RTFitaFlg% OR RTFundFlg% OR RTFcndFlg% OR RTFsupFlg% OR RTFsubFlg%
  990. 5410  END IF 
  991. 5420 END SUB 
  992.  
  993. 5440 SUB RTFsubscriptON
  994. 5450  IF RTFsubFlg%=0 THEN 
  995. 5460   CALL RTFendEnhance
  996.        RTFenhFlg%=1
  997. 5470   RTFsubFlg%=1
  998. 5480  END IF 
  999. 5490 END SUB 
  1000.  
  1001. 5510 SUB RTFsubscriptOFF
  1002. 5520  IF RTFsubFlg%<>0 THEN 
  1003. 5530   CALL RTFendEnhance
  1004. 5540   RTFsubFlg%=0
  1005.        RTFenhFlg%=RTFbldFlg% OR RTFitaFlg% OR RTFundFlg% OR RTFcndFlg% OR RTFsupFlg% OR RTFsubFlg%
  1006. 5550  END IF 
  1007. 5560 END SUB 
  1008.  
  1009. ' The following subroutine is no longer needed
  1010.  
  1011. '5580 SUB RTFbeginEnhance
  1012. '5590  IF RTFenhFlg%=0 THEN 
  1013. '5600    RTFo$=RTFo$ + "}"
  1014. '5610    RTFbldFlg%=0
  1015. '5620    RTFitaFlg%=0
  1016. '5630    RTFundFlg%=0
  1017. '5640    RTFcndFlg%=0
  1018. '5650    RTFsupFlg%=0
  1019. '5660    RTFsubFlg%=0
  1020. '5670    RTFenhFlg%=1
  1021. '5680  END IF 
  1022.  
  1023. SUB RTFendEnhance
  1024. 5590  IF RTFenhFlg%=0 THEN 
  1025. 5595   IF (RTFbldFlg% OR RTFitaFlg% OR RTFundFlg% OR RTFcndFlg% OR RTFsupFlg% OR RTFsubFlg%) THEN 
  1026. 5600    RTFo$=RTFo$+"}"
  1027. 5605   END IF 
  1028. 5606  END IF 
  1029. 5607 END SUB 
  1030.  
  1031. SUB RTFclearEnhance
  1032. 5610  RTFbldFlg%=0
  1033. 5620  RTFitaFlg%=0
  1034. 5630  RTFundFlg%=0
  1035. 5640  RTFcndFlg%=0
  1036. 5650  RTFsupFlg%=0
  1037. 5660  RTFsubFlg%=0
  1038. 5670  RTFenhFlg%=0
  1039. 5690 END SUB
  1040.  
  1041. 5710 SUB RTFflushEnhance
  1042. 5720  IF RTFenhFlg% THEN 
  1043. 5730   RTFo$=RTFo$ + "{"
  1044. 5740   IF RTFbldFlg% THEN 
  1045. 5750    RTFo$=RTFo$ + "\b "
  1046. 5760   END IF 
  1047. 5770   IF RTFitaFlg% THEN 
  1048. 5780    RTFo$=RTFo$ + "\i "
  1049. 5790   END IF 
  1050. 5800   IF RTFundFlg% THEN 
  1051. 5810    RTFo$=RTFo$ + "\ul "
  1052. 5820   END IF 
  1053. 5830   IF RTFcndFlg% THEN 
  1054. 5840    RTFo$=RTFo$ + "\expnd58 "
  1055. 5850   END IF 
  1056. 5860   IF RTFsupFlg% THEN 
  1057. 5870    RTFo$=RTFo$ + "\up6 "
  1058. 5880   END IF 
  1059. 5890   IF RTFsubFlg% THEN 
  1060. 5900    RTFo$=RTFo$ + "\dn4 "
  1061. 5910   END IF 
  1062. 5920  END IF 
  1063. 5930  RTFenhFlg%=0
  1064. 5940 END SUB 
  1065.  
  1066. SUB RTFtabout
  1067. 5952  IF RTFenhFlg% THEN CALL RTFflushEnhance
  1068. 5953  RTFo$=RTFo$+"\tab "
  1069. END SUB
  1070.  
  1071. SUB RTFpagebreak
  1072. 5957  PRINT#9;"\page "
  1073. END SUB
  1074.  
  1075. 5960 SUB RTFoutChar(t$)
  1076. 5965 LOCAL K%,C%
  1077. 5970  IF RTFenhFlg% THEN 
  1078. 5980    CALL RTFflushEnhance
  1079. 5990  END IF 
  1080.       K%=ASC(t$)
  1081. 5993  SELECT ON K%
  1082. 5995  =ASC("{"),ASC("}"),ASC("\"):RTFo$=RTFo$+"\"+t$
  1083. 5996  =32 TO 126:RTFo$=RTFo$+t$
  1084.       =127 TO 255
  1085.          C%=ANSI%(K%)
  1086. '        PRINT "In: ";K%;" -> ";C% : MouseWait
  1087.          IF C%<128 THEN                             
  1088.              RTFo$=RTFo$+CHR$(C%)
  1089.            ELSE
  1090.              RTFo$=RTFo$+"\'"+HEX8$(C%)
  1091.          END IF
  1092. 5998  =REMAINDER
  1093.          RTFo$=RTFo$+"\'"+HEX8$(C%) ' Control codes?!
  1094. 6000  END SELECT
  1095. END SUB 
  1096.  
  1097. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  1098.  
  1099. REM Character code conversion tables
  1100.  
  1101. REM PC ASCII TO ANSI CODE CONVERSION TABLE, PROVIDED BY CHAS DILLON
  1102.  
  1103. PC_CODES:
  1104.  
  1105. DATA  63, 199, 252                                    : ' 127 - 129
  1106. DATA 233, 226, 228, 224, 229, 231, 234, 235, 232, 239 : ' 130 - 139
  1107. DATA 238, 236, 196, 197, 201, 230, 198, 244, 246, 243 : ' 140 - 149
  1108. DATA 251, 249, 255, 214, 220, 162, 163, 165,  63,  63 : ' 150 - 159
  1109. DATA 225, 237, 243, 250, 241, 209,  63, 186, 191,  63 : ' 160 - 169
  1110. DATA 172, 189, 188, 161, 171, 187,  63,  63,  63,  63 : ' 170 - 179
  1111. DATA  63,  63,  63,  63,  63,  63,  63,  63,  63,  63 : ' 180 - 189
  1112. DATA  63,  63,  63,  63,  63,  63,  63,  63,  63,  63 : ' 190 - 199
  1113. DATA  63,  63,  63,  63,  63,  63,  63,  63,  63,  63 : ' 200 - 209
  1114. DATA  63,  63,  63,  63,  63,  63,  63,  63,  63,  63 : ' 210 - 219
  1115. DATA  63,  63,  63,  63,  63, 223,  63,  63,  63,  63 : ' 220 - 229
  1116. DATA  63,  63,  63,  63,  63,  63,  63,  63,  63,  63 : ' 230 - 239
  1117. DATA  63,  63,  63,  63,  63,  63, 247,  63,  63,  63 : ' 240 - 249
  1118. DATA  63,  63,  63, 178,  63,  63                     : ' 250 - 255
  1119.  
  1120. REM Untranslatable codes replaced with 63 to display as question marks.
  1121. REM German Sz/Greek Beta (ANSI 223) added by SNG at table position 225.
  1122. REM Use this to translate PC Quill accented and extra (non 7 bit ASCII)
  1123. REM codes to `standard' ANSI codes, used by Amiga and Windoze programs.
  1124. REM It includes French E, A and U grave, E acute, C circumflex, Spanish
  1125. REM N tildes & inverted ? and !, German Beta/Sz and O, A and U umlauts.  
  1126.  
  1127. REM QL ASCII TO ANSI CODE CONVERSION TABLE, ENTERED BY SIMON N GOODWIN.
  1128.  
  1129. QL_CODES:
  1130.  
  1131. DATA 169, 228, 227                                    : ' 127 .. 129
  1132. DATA 229, 233, 246, 245, 248, 252, 231, 241, 230,  69 : ' 130 .. 139
  1133. DATA 225, 224, 226, 235, 232, 234, 239, 237, 236, 238 : ' 140 .. 149
  1134. DATA 243, 242, 244, 250, 249, 251, 223, 162, 165,  96 : ' 150 .. 159
  1135. DATA 196, 195, 197, 201, 214, 213, 216, 220, 199, 209 : ' 160 .. 169  
  1136. DATA 198,  63,  63, 240,  63,  63, 181,  63,  63, 161 : ' 170 .. 179
  1137. DATA 191,  63, 167, 164, 171, 187, 176, 247,  63,  63 : ' 180 .. 189
  1138. DATA  63,  63,  63,  63,  63,  63,  63,  63,  63,  63 : ' 190 .. 199
  1139. DATA  63,  63,  63,  63,  63,  63,  63,  63,  63,  63 : ' 200 .. 209
  1140. DATA  63,  63,  63,  63,  63,  63,  63,  63,  63,  63 : ' 210 .. 219
  1141. DATA  63,  63,  63,  63,  63,  63,  63,  63,  63,  63 : ' 220 .. 229
  1142. DATA  63,  63,  63,  63,  63,  63,  63,  63,  63,  63 : ' 230 .. 239
  1143. DATA  63,  63,  63,  63,  63,  63,  63,  63,  63,  63 : ' 240 .. 249
  1144. DATA  63,  63,  63,  63,  63,  63                     : ' 250 .. 255
  1145.  
  1146. ' MISSING: oe/OE ellipsis (139, 171), Alpha, Theta, Lambda, Pi, Phi (172,
  1147. ' 174, 175, 177, 178), Backward S (181), arrowheads (188, 189, 190, 191).
  1148. ' Amiga codes from Mapping the Amiga - checked by inspection of Topaz and
  1149. ' Clean fonts - note: the table in the A2000 Amiga BASIC manual is WRONG!
  1150. ' This SuperBASIC show Qdos codes: FOR I=127 TO 191 : PRINT I!!CHR$(I)!!!
  1151. ' This table translates QL & Thor Quill accents and other non 7 bit ASCII
  1152. ' codes into the ANSI character codes used by Amiga AND Windoze programs.
  1153.